<template>
<!-- 价格优先级 -->
    <div>
        <el-input style="width:27%" disabled v-model="checkedData"></el-input>
    </div>
</template>

<script>
import nonStandardService from '@/services/nonStandardService'
import eventBus from '@/assets/utils/eventBus.js'
export default {
    name: 'pricePriority',
    props: {
        detail: {
            type: Object,
            default: () => {
                return {}
            } 
        },
        value: [Object, String],
        disabled: Boolean,
        parameter: {
            type: Object,
            default: () => {
                return {}
            } 
        },
        data:{
            type: Object,
            default:() => {}
        }
    },
    data(){
        return {
            checkedData: 4,
        }
    },
    created(){
        if(this.value){
            this.setData();
        }
        this.$emit('input',String(this.checkedData))
        eventBus.$on('changeValue',() => {
            this.$emit('input',String(this.checkedData))
        })
        eventBus.$on('statusChange', () => {
            this.queryData();
        })
    },
    methods: {
        queryData(){
            /** 价格优先级 this.checkedData
             * 1不限  2指定
             * goodsType         propertyType & modelType        categoryType
             * 0 货品：指定;     固定属性&型号：都不是指定;       品名：不限or无;
             * 1 货品：不限or无; 固定属性&型号：存在一个指定;     品名：指定;
             * 2 货品：不限or无; 固定属性&型号：都不是指定;       品名：指定;
             * 3 货品：不限or无; 固定属性&型号：存在一个指定;     品名：不限or无;
             * 4 其他
            */
            let goodsType = localStorage.getItem('goodsType');
            let propertyType = localStorage.getItem('propertyType');
            let modelType = localStorage.getItem('modelType');
            let categoryType = localStorage.getItem('categoryType');
            if(goodsType == 2 && (propertyType != 2 && modelType != 2) && categoryType != 2){
                this.checkedData = 0;
            }else if(goodsType != 2 && (propertyType == 2 || modelType == 2) && categoryType == 2){
                this.checkedData = 1;
            } else if(goodsType != 2 && (propertyType != 2 && modelType != 2) && categoryType == 2){
                this.checkedData = 2;
            } else if(goodsType != 2 && (propertyType == 2 || modelType == 2) && categoryType != 2){
                this.checkedData = 3;
            } else {
                this.checkedData = 4;
            }
            this.$emit('input',String(this.checkedData))
        },
        setData(){
            this.checkedData = JSON.parse(this.value).value ? JSON.parse(this.value).value : 4;
        },
        getData(){
            return {
                value: this.checkedData
            } 
        }
    }
}
</script>

<style>

</style>